package com.zhuj.client.proxy;

import java.lang.reflect.Proxy;

/**
 * Created by Administrator on 2018/1/3.
 */
public class ProxyFactory<T> {

    private static ProxyFactory proxyFactory = null;

    private ProxyFactory(){}

    public static ProxyFactory newInstance(){
        if (proxyFactory == null){
            proxyFactory = new ProxyFactory();
            return proxyFactory;
        }
        return proxyFactory;
    }

    public<T> T getNewInstance(Class<T> target){
        return (T) Proxy.newProxyInstance(target.getClassLoader(),
            new Class[]{target},new NrpcInvocationHandler(target));
    }

}
